package com.mpgame.database.mysql.mapper.game;

import com.mpgame.database.mysql.mapper.BaseMapper;
import com.mpgame.database.mysql.model.game.Skills;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface SkillsMapper extends BaseMapper<Skills> {
    
    @Insert("INSERT INTO skills (name, family_id, power, pp, priority, effect, additional_effect, accuracy, description) VALUES (#{name}, #{familyId}, #{power}, #{pp}, #{priority}, #{effect}, #{additionalEffect}, #{accuracy}, #{description})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Skills skills);

    @Select("SELECT * FROM skills WHERE id = #{id}")
    Skills selectById(@Param("id") int id);

    @Select("SELECT * FROM skills WHERE name = #{name}")
    Skills selectByName(@Param("name") String name);

    @Select("SELECT * FROM skills WHERE family_id = #{familyId}")
    List<Skills> selectByFamilyId(@Param("familyId") int familyId);

    @Select("SELECT * FROM skills")
    List<Skills> selectAll();

    @Update("UPDATE skills SET name = #{name}, family_id = #{familyId}, power = #{power}, pp = #{pp}, priority = #{priority}, effect = #{effect}, additional_effect = #{additionalEffect}, accuracy = #{accuracy}, description = #{description} WHERE id = #{id}")
    int updateById(Skills skills);
}
